#!/bin/bash

#This is an example sequence of commands for running the default Kaldi Babel OP1 system
#It is not assumed that you will run it as a script, even though you can try :)

./run-1-main.sh

##Training of the automatic segmenter
./run-2-segmentation.sh

##Decoding the automatic segmentation of dev2h subset. dev2h.pem would mean decoding
##the dev2h subset using the officialy provided segmentation.
##Also possible to run dev10h.pem, dev10h.uem, dev10h.seg and so on...
./run-4-anydecode.sh --dir dev10h.pem

##Decoding of the dev10h (all systems, all stages)
./run-4-anydecode.sh --dir dev10h.seg --extra-kws true

##Decoding of the shadow.seg (combination of dev10h.seg and eval.seg)
##We did this for eval run as a kind of "sanity check" -- we check the shadow.seg/dev10h.seg subset
##performance vs the standalone dev10h.seg performance to catch (hopefully) possible problems
./run-4-anydecode.sh --dir shadow.seg --extra-kws true


#This prepares for separation/split of the shadow dataset into the devset, which we can evaluate
# and the eval set, which we will submit
#Note: we do this only once, for ./data, as we do not really need anything else
#just the file lists...
#NB: there was a oversight in one of the scripts that was causing thectm files contain
#BN: incorrect channel info (A instead of 1)
#NB: To fix that, you can run something like this:
#NB: find exp/ -name "shadow.seg.ctm" | xargs -t -n 1 sed -i'.bakx' 's/ A / 1 /g'
./local/nist_eval/create_compound_set.sh --evlset eval.seg --devset dev10h.seg --tgtdir data/shadow.seg

./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg dev10h.seg exp/tri6b_nnet/decode_shadow.seg
./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg eval.seg   exp/tri6b_nnet/decode_shadow.seg

./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg dev10h.seg exp/sgmm5_mmi_b0.1/decode_*shadow.seg*
./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg eval.seg   exp/sgmm5_mmi_b0.1/decode_*shadow.seg*

./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg dev10h.seg exp_bnf/sgmm7_mmi_b0.1/decode_*shadow.seg*
./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg eval.seg   exp_bnf/sgmm7_mmi_b0.1/decode_*shadow.seg*

./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg dev10h.seg exp_bnf_semisup/sgmm7_mmi_b0.1/decode_*shadow.seg*
./local/nist_eval/filter_data.sh  --cmd "$decode_cmd"  data/shadow.seg eval.seg   exp_bnf_semisup/sgmm7_mmi_b0.1/decode_*shadow.seg*

#The following commands will actually do two things
#a) looking at the performance of the dataset --master <dataset> they will figure out the correct LMW
#b) symlink the appropriate evaluation result file under the correct EXPID into the ./release directory
#Warning: it's a lot of files so it's easy to get confused!
./local/nist_eval/make_release.sh --dryrun false --dir exp/sgmm5_mmi_b0.1 --data data/shadow.seg --master dev10h.seg lang.conf ./release
./local/nist_eval/make_release.sh --dryrun false --dir exp/tri6b_nnet --data data/shadow.seg --master dev10h.seg lang.conf ./release
./local/nist_eval/make_release.sh --dryrun false --dir exp_bnf/sgmm7_mmi_b0.1 --data data/shadow.seg --master dev10h.seg lang.conf ./release
./local/nist_eval/make_release.sh --dryrun false --dir exp_bnf_semisup/sgmm7_mmi_b0.1 --extrasys SEMISUPX --data data/shadow.seg --master dev10h.seg lang.conf ./release

#Combine results (what we call 4way-combo)

